package com.ruoyi.rsikManage.controller;

import java.util.List;


import com.ruoyi.rsikManage.domain.TReportType;
import com.ruoyi.rsikManage.service.ITReportTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.servlet.http.HttpServletResponse;

/**
 * 报备类型字典Controller
 * 
 * @author ruoyi
 * @date 2023-08-08
 */
@RestController
@RequestMapping("/zdzh/reportType")
public class TReportTypeController extends BaseController
{
    @Autowired
    private ITReportTypeService tReportTypeService;

    /**
     * 查询报备类型字典列表
     */
    //@PreAuthorize("@ss.hasPermi('zdzh:reportType:list')")
    @GetMapping("/list")
    public TableDataInfo list(TReportType tReportType)
    {
        startPage();
        List<TReportType> list = tReportTypeService.selectTReportTypeList(tReportType);
        return getDataTable(list);
    }

    /**
     * 导出报备类型字典列表
     */
    //@PreAuthorize("@ss.hasPermi('zdzh:reportType:export')")
    @Log(title = "报备类型字典", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public void export(HttpServletResponse response,TReportType tReportType)
    {
        List<TReportType> list = tReportTypeService.selectTReportTypeList(tReportType);
        ExcelUtil<TReportType> util = new ExcelUtil<TReportType>(TReportType.class);
         util.exportExcel(response,list, "reportType");
    }

    /**
     * 获取报备类型字典详细信息
     */
   // @PreAuthorize("@ss.hasPermi('zdzh:reportType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tReportTypeService.selectTReportTypeById(id));
    }

    /**
     * 新增报备类型字典
     */
    //@PreAuthorize("@ss.hasPermi('zdzh:reportType:add')")
    @Log(title = "报备类型字典", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TReportType tReportType)
    {
        return toAjax(tReportTypeService.insertTReportType(tReportType));
    }

    /**
     * 修改报备类型字典
     */
   // @PreAuthorize("@ss.hasPermi('zdzh:reportType:edit')")
    @Log(title = "报备类型字典", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TReportType tReportType)
    {
        return toAjax(tReportTypeService.updateTReportType(tReportType));
    }

    /**
     * 删除报备类型字典
     */
    //@PreAuthorize("@ss.hasPermi('zdzh:reportType:remove')")
    @Log(title = "报备类型字典", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tReportTypeService.deleteTReportTypeByIds(ids));
    }
}
